<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.commons.Constants"%>
<%@ page import="com.scalar.chiptrack.users.User"%>
<%@ page import="com.scalar.chiptrack.users.Functionality"%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/releaseMarkingSetup.do?action=releaseMarkingSetup" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<html>
    <HEAD>
    <TITLE>Scalarsoft - ChipTrac</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
    <script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
    <script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
    <script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>     
    <SCRIPT language="JavaScript">
    var errors;
    var chiptracErrors;
    var chiptracInfo;
    var form;
    window.onload = init;
    function init()
    {
        errors = document.getElementById("errors");
        chiptracErrors = document.getElementById("chiptracErrors");
        chiptracInfo = document.getElementById("chiptracInfo");
        form = document.releaseInfoSetupForm;
       
        if ( form.processStepId  != null)
        {
            qs_1 = new QuickSearch( form.processStepId, form.qs1, false);
        }
    }

    function loadReleaseInfoSetup()
    {
        var processType = form.processType.value;
        var vendorId    = form.vendorId.value;
        var category    = form.category.value;

        if( vendorId != '-1' && ( processType == '0' || processType == '-1' ) )
        {
            chiptracErrors.innerHTML = '';
            chiptracInfo.innerHTML = '';
            errors.innerHTML = "<li> Please select a Process Type";
            return false;
        }
        if( category != '-1' && ( vendorId == '0' || vendorId == '-1' ) )
        {
            chiptracErrors.innerHTML = '';
            chiptracInfo.innerHTML = '';
            errors.innerHTML = "<li> Please select a Vendor";
            form.category.selectedIndex = 0;
            return false;
        }
        form.action = form.action+"?action=load";
        form.submit();
    }

    function resetCategory()
    {
        form.category.selectedIndex = 0;
        loadReleaseInfoSetup();
    }

    function resetVendorAndReleaseType()
    {
        if( ( typeof form.vendorId != "undefined" ) && ( typeof form.category != 'undefined' ) )
        {
            form.vendorId.selectedIndex     = 0;
            form.category.selectedIndex  = 0;
            loadReleaseInfoSetup();
        }
    }

    function loadvendors()
    {
        var processStepId = form.processStepId.value;
        if( processStepId == '-1')
        {
            chiptracErrors.innerHTML = '';
            chiptracInfo.innerHTML = '';
            form.action = form.action+"?action=loadPartNumbers";
            form.submit();
            return;
        }
        form.action = form.action+"?action=LoadVendors";
        form.submit();
    }
    function loadDetails()
    {
        var vendorId = form.vendorId.value;
        if( vendorId == '-1')
        {
            chiptracErrors.innerHTML = '';
            chiptracInfo.innerHTML = '';
            form.action = form.action+"?action=LoadVendors";
            form.submit();
            return;
        }
        form.action = form.action+"?action=loadMarkingDetails";
        form.submit();
    }
    function saveReleaseInfoSetup()
    {
        var vendorId = form.vendorId.value;
        var processStepId = form.processStepId.value;
        var markingFirstLine = form.markingFirstLine.value;
        var markingSecondLine = form.markingSecondLine.value;
        var markingThirdLine = form.markingThirdLine.value;
        var markingFourthLine = form.markingFourthLine.value;
        var markingFifthLine = form.markingFifthLine.value;
        var markingSixthLine = form.markingSixthLine.value;

        if ( markingFirstLine.trim().length > 0 || markingSecondLine.trim().length > 0 || markingThirdLine.trim().length > 0 || markingFourthLine.trim().length > 0 || markingFifthLine.trim().length > 0 || markingSixthLine.trim().length > 0 )
        {
            form.action = form.action+"?action=save";
            form.submit();
        }
        else
        {
            chiptracErrors.innerHTML = '';
            chiptracInfo.innerHTML = '';
            errors.innerHTML = "<li> Please Enter Atleast one Marking Line";
        }
    }
    function reset()
    {
        form.reset();
        qs_1.resetQuickSearchCntrl();
    }

    function checkDefault( chkboxCtrl )
    {
        var contactPersonsCount = form.contactPersonsCount.value;
        var iHitCount = 0;
        var isChecked = chkboxCtrl.checked;
        if( contactPersonsCount >= 0)
        {
            for( var idx = 0; idx <= contactPersonsCount; idx ++ )
            {
                form['contactPersonsList['+idx+'].primary'].checked = false;
            }
        }
        chkboxCtrl.checked = isChecked;
    }

</script>

</HEAD>
<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
    <!-- Top Header Start-->
    <%@ include file="/jsp/includes/header.jsp" %>
    <!-- Top Header End-->
    <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
      <TBODY >
      <TR>
        <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

        <!-- Side Navigation start -->
        <%@ include file="/jsp/operations/releaseMenu.jsp" %></TD>
        <!-- end of the side navigations -->

        <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">

        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>
        <!-- from here your body starts -->
        <html:form action="/releaseMarkingSetup" name="releaseInfoSetupForm" type="com.scalar.chiptrack.operations.release.forms.ReleaseInfoSetupForm">
            <TABLE width='80%' align=center cellpadding='3' cellspacing='2' border='0'>
                <tr><td colspan='4' class="NArialW" align=center>Assembly Release Marking Info Setup</td></tr>
                <logic:equal name="showMessage" value="TRUE">
                <tr><td colspan='4' align='left'><font class='NArialS' color='blue'><B><%=Constants.NO_MODIFY_RIGHTS %></B></font></td></tr>
                </logic:equal>
                <tr><td colspan='4' align="left" class='NArialL'><FONT id="errors" color='FF0000'></font>&nbsp;</td></tr>
                <tr><td colspan='4' id='chiptracErrors'><chiptrack:errors styleClass="NArialL"/></td></tr>
                <tr><td colspan='4' id='chiptracInfo'><chiptrack:info styleClass="NArialL"/></td></tr>
                <logic:present name="partNumbersList" >
                <TR>
                    <TD class="NArialL" width='20%'>Quick Search:</TD>
                    <td class="NArialL" width='25%'>
                    <input type="text" name="qs1" class="txfield" size='23' onkeyup='quickSearch(qs_1)'/>
                    </td>
                    <TD COLSPAN=2>&nbsp;</TD>
                </TR>
                </logic:present>
                <tr>
                    <td class='NArialL' align="center" width='20%'> Part Number :<font color="RED" size="1"><B>*</B></font></td>
                    <td class="NArialL" width='25%'>
                        <html:select property="processStepId" name="releaseInfoSetupForm" styleClass="txfield"  onchange="loadvendors()">
                        <html:option value="-1">--Select Part Number--</html:option>
                        <html:options collection="partNumbersList" property="value" labelProperty="label"/>
                        </html:select>
                    </td>
                    <logic:present name="vendorList" >

                    <td class="NArialL" align="center" width='20%'> Vendor :<font color="RED" size="1"><B>*</B></font></td>
                    <td class="NArialL" width='30%'>
                        <html:select property="vendorId" name="releaseInfoSetupForm" styleClass="txfield"  onchange="javascript:loadDetails();">
                        <html:option value="-1">--Select Vendor--</html:option>
                        <html:options collection="vendorList" property="value" labelProperty="label"/>
                        </html:select>
                    </td>
                    </logic:present>
                    <logic:notPresent name="vendorList" >
                        <td width='20%'>&nbsp;</td>
                        <td width='35%'>&nbsp;</td>
                   </logic:notPresent>
                </tr>
                <logic:present name="vendorList" >
                <logic:equal value="true" property="displayForm" name="releaseInfoSetupForm">
                <tr>
                    <td width="10%" > </td>
                    <td colspan='4' width="50%" valign="top">
                        <table border="0" width="50%" align="left" cellpadding="3" cellspacing="2">
                            <tr>
                                <td class="NArialL" colspan="2">Marking :<font color="RED" size="1"><B>*</B></font></td>
                            </tr>
                            <tr>
                                <td width='40%' align="center" bgcolor="#993333"><font class="NArialL" color="#FFFFFF">&nbsp;</font></td>
                                <td width='60%' align="center" bgcolor="#993333"><font class="NArialL" color="#FFFFFF">&nbsp;</font></td>
                            </tr>
                            <tr>
                                <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">First Line</font></td>
                                <td align="center" bgcolor="#DEE1E2">
                                    <font class="NArialL" color="#FFFFFF">
                                        <nested:text property="markingFirstLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">Second Line</font></td>
                                <td align="center" bgcolor="#DEE1E2">
                                    <font class="NArialL" color="#FFFFFF">
                                        <nested:text property="markingSecondLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">Third Line</font></td>
                                <td align="center" bgcolor="#DEE1E2">
                                    <font class="NArialL" color="#FFFFFF">
                                        <nested:text property="markingThirdLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">Fourth Line</font></td>
                                <td align="center" bgcolor="#DEE1E2">
                                    <font class="NArialL" color="#FFFFFF">
                                        <nested:text property="markingFourthLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                    </font>
                                </td>
                            </tr>
                            <tr>
                                 <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">Fifth Line</font></td>
                                 <td align="center" bgcolor="#DEE1E2">
                                     <font class="NArialL" color="#FFFFFF">
                                         <nested:text property="markingFifthLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                     </font>
                                 </td>
                             </tr>
                            <tr>
                                 <td align="center" bgcolor="#DEE1E2"><font class="NArialL" color="#FFFFFF">Sixth Line</font></td>
                                 <td align="center" bgcolor="#DEE1E2">
                                     <font class="NArialL" color="#FFFFFF">
                                         <nested:text property="markingSixthLine" name="releaseInfoSetupForm" styleClass="txfield" size="40" maxlength="50"/>
                                     </font>
                                 </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='20'></td></tr>
                <tr>
                    <td colspan='4' align=center>
                        <chiptrack:restrictedLink functionality='<%=Functionality.RELEASE_INFO_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:saveReleaseInfoSetup();" onmouseover="window.status='Click here to save';return true" onmouseout="window.status='';return true">
                        <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" title=""></chiptrack:restrictedLink>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset" ></a>
                    </td>
                </tr>
                 </logic:equal>
                 </logic:present>
            </TABLE>
        </html:form>
    </td>
    </tr>
    </TABLE>
        <!-- Footer starts here -->
        <%@ include file="/jsp/includes/footer.jsp" %>
        <!-- footer end here -->
    </body>
</html>
